package com.meichis.yndms.adapter;

import android.content.Context;
import android.graphics.Bitmap;

import com.meichis.mcsappframework.adapter.abslistview.CommonAdapter;
import com.meichis.mcsappframework.adapter.abslistview.ViewHolder;
import com.meichis.yndms.R;
import com.meichis.yndms.model.VisitTemplateDetail;
import com.nostra13.universalimageloader.core.DisplayImageOptions;

import java.util.List;

/**
 * Created by chenhaifei on 2016/8/25.
 */
public class VSTTemplateAdapter extends CommonAdapter<VisitTemplateDetail> {
    private DisplayImageOptions options;

    public VSTTemplateAdapter(Context context, int layoutId, List datas) {
        super(context, layoutId, datas);
        options = new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.emptyphoto).showImageForEmptyUri(R.mipmap.emptyphoto).showImageOnFail(R.mipmap.emptyphoto).cacheInMemory(true)
                .bitmapConfig(Bitmap.Config.RGB_565).cacheOnDisk(true).considerExifParams(true).build();
    }

    @Override
    protected void convert(ViewHolder viewHolder, VisitTemplateDetail item, int position) {
        viewHolder.setText(R.id.txt_name, item.getProcess().getName());
        viewHolder.setText(R.id.tv_message, item.getRemark());
        viewHolder.setImageResource(R.id.iv_ico, R.mipmap.emptyphoto);
        viewHolder.setVisible(R.id.tv_state,!item.isCanSkip());
        if (item.getProcess().getExtParams().containsKey("ICON")) {
            viewHolder.setImageURL(R.id.iv_ico, item.getProcess().getExtParams().get("ICON").toString(), options);
        }
    }
}
